package cn.tedu;

import java.sql.*;

public class Demo03 {
    public static void main(String[] args) throws SQLException {
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/empdb?characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSl=false",
                "root","root");
        //创建执行sql语句的对象
        Statement s = conn.createStatement();
//        //执行sql语句
//        s.execute("drop table zhangsan");
//        conn.close();
//        System.out.println("执行完毕!");


      //执行sql语句
        ResultSet rs = s.executeQuery("select name,sal,job from emp");
        while (rs.next()){
            //获取结果集对象中游标指向的数据
            String name = rs.getString("name");
            double sal = rs.getDouble("sal");
            String job = rs.getString("job");
            System.out.println(name+":"+sal+":"+job);
        }
        conn.close();
    }
}

